<template>
  <div>
    <!-- 增加产品分类 -->
    <Dialog :title="title" :visible="show" class="single-column" :button-text="testBtn" @confirm="submitForm" @close="handleClose">
      <div>
        <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="100px" class="demo-ruleForm" label-position="right">
          <!-- <el-form-item label="编号：" prop="no">
            <span>{{ ruleForm.no }}</span>
          </el-form-item> -->
          <el-form-item label="名称：" prop="dataName">
            <el-input v-model="ruleForm.dataName" />
          </el-form-item>
          <!-- <el-form-item label="医院：">
        <el-select v-model="value" placeholder="一级分类">
          <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
        </el-select>
      </el-form-item>
      <el-form-item label="上级分类：">
        <el-select v-model="value" placeholder="一级分类">
          <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
        </el-select>
      </el-form-item> -->
          <el-form-item label="状态：" prop="status">
            <el-radio-group v-model="ruleForm.status">
              <el-radio label="启用" />
              <el-radio label="停用" />
            </el-radio-group>
          </el-form-item>
        </el-form>
      </div>
    </Dialog>
  </div>
</template>
<script>
import Dialog from '@/components/Dialog';
export default {
  components: {
    Dialog,
  },
  props: {
    show: {
      type: Boolean,
      define: false,
    },
  },
  data() {
    return {
      ruleForm: {
        status: "启用",
      },
      options: [],
      title: '',
      testBtn: '保存',
      // visible: false,
      rules: {
        dataName: [
          { required: true, message: '请输入产品名称', trigger: 'blur' },
        ],
      },
    };
  },
  watch: {

  },
  methods: {
    submitForm() {
      this.$refs.ruleForm.validate((valid) => {
        if (valid) {
          this.$emit('submitForm', this.ruleForm);
          this.$emit('update:show', false);
          this.$refs.ruleForm.resetFields();
        } else {
          return this.$message.info('请输入产品名称！');
        }
      });
    },
    addBtn(name) {
      this.title = name;
    },
    editBtn(row) {
      // console.log(row, 'oss');
      this.ruleForm = row;
      this.title = "编辑分类";
    },
    handleClose() {
      this.$emit('update:show', false);
      // this.$refs.ruleForm.resetFields();
    },
  },
};
</script>
<style lang="scss" scoped>
.dialog-magin-y{
  margin: 0 150px;
}
</style>
